package com.haixin.security.service.impl;

import com.haixin.security.bean.RolePermission;
import com.haixin.security.dao.RolePermissionMapper;
import com.haixin.security.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class RolePermissionServiceImpl implements RolePermissionService {
    @Autowired
    private RolePermissionMapper rolePermissionMapper;

    @Override
    public List<RolePermission> getAllRolePermissions() {
        return rolePermissionMapper.getAllRolePermissions();
    }

    @Override
    public List<Integer> getPermissionsByRoleId(int roleId) {
        return rolePermissionMapper.getPermissionsByRoleId(roleId);
    }

    @Override
    public boolean addRolePermission(RolePermission rolePermission) {
        return rolePermissionMapper.insertRolePermission(rolePermission) > 0;
    }

    @Override
    public boolean removeRolePermissionsByRoleId(int roleId) {
        return rolePermissionMapper.deleteRolePermissionsByRoleId(roleId) > 0;
    }

    @Override
    public boolean removeRolePermission(RolePermission rolePermission) {
        return rolePermissionMapper.deleteRolePermission(rolePermission) > 0;
    }
}
